﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Account_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void LoginUser_LoggingIn(object sender, LoginCancelEventArgs e)
    {
        //此方法一般用来验证输入是否正确
        //if (!IsValidEmail(Login1.UserName))
        //{
        //    Login1.InstructionText = "You must enter a valid e-mail address.";
        //    e.Cancel = true;
        //}
        //else
        //{
        //    Login1.InstructionText = String.Empty;
        //}

    }
    protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)
    {
        //此方法用来进行自验证
        bool Authenticated = false;
        Authenticated = SiteSpecificAuthenticationMethod(LoginUser.UserName,LoginUser.Password);

        e.Authenticated = Authenticated;

    }
    private bool SiteSpecificAuthenticationMethod(string username,string password)
    {
        
        bool usrpwdValid = Membership.ValidateUser(username, password);
        bool webAccessValid=BaseInfoCtrl.AuthenticateUser(username);
        if (usrpwdValid == true && webAccessValid == true)
            return true;
        else
            return false;
    }
}
